package com.tiansu.reborn.wanda.modules.executor.controller;


import com.alibaba.excel.EasyExcel;
import com.tiansu.reborn.wanda.modules.executor.dao.TVPaymentDeviceDao;
import com.tiansu.reborn.wanda.modules.executor.entity.MakeupRechargeEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

@Controller
public class MakeupReChargeController {

    @GetMapping("/makeup_recharge")
    public String MakeupReCharge(){
        return "makeup_recharge";
    }

    @Value("${my.batchurl}")
    private String url;

    @Resource
    private TVPaymentDeviceDao tvPaymentDeviceDao;

    @PostMapping("/upload")
    @ResponseBody
    public String  upload(MultipartFile file) throws IOException{
        EasyExcel.read(file.getInputStream(), MakeupRechargeEntity.class,new UploadDataListener(tvPaymentDeviceDao,url)).sheet().doRead();
        return "success";
    }

}
